package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("userShopController")
@RequestMapping("/user/shop")//这里每次还是需要看一下接口文档
@Slf4j
@Api(tags = "用户端营业状态接口")
public class ShopController {

    @Autowired
    RedisTemplate redisTemplate;

    private static final String KEY="SHOP_STATUS";

    /**
     * 获得营业状态
     * @return
     */
    @GetMapping("/statue")
    @ApiOperation("查询营业状态")
    public Result<Integer> findShopStatus(){
        Integer status= (Integer) redisTemplate.opsForValue().get(KEY);
        log.info("查询营业状态",status==1?"营业中":"打烊中");
        return Result.success(status);
    }


}
